package com.shambles.manage2.redis;

import com.shambles.manage2.dto.SysUserDTO;
import net.jodah.expiringmap.ExpirationPolicy;
import net.jodah.expiringmap.ExpiringMap;

import java.util.Map;
import java.util.concurrent.TimeUnit;

public class LocalCache {
    private static Map<String, SysUserDTO> LOCAL_CACHE  = ExpiringMap.builder().expiration(6*60*60*1000, TimeUnit.MILLISECONDS)
            .expirationPolicy(ExpirationPolicy.CREATED)
            .build();
    public static void put(String key,SysUserDTO userDTO){
        LOCAL_CACHE.put(key, userDTO);
    }
    public static SysUserDTO get(String key){
       return LOCAL_CACHE.get(key);
    }

    public static void remove(String tokenId) {
        LOCAL_CACHE.remove(tokenId);
    }
}
